package migrations

import (
	"github.com/goravel/framework/contracts/database/schema"
	"github.com/goravel/framework/facades"
)

type M20250303170434CreateBusgroupModulesTable struct {
}

// Signature The unique signature for the migration.
func (r *M20250303170434CreateBusgroupModulesTable) Signature() string {
	return "20250303170434_create_busgroup_modules_table"
}

// Up Run the migrations.
func (r *M20250303170434CreateBusgroupModulesTable) Up() error {
	if !facades.Schema().HasTable("busgroup_modules") {
		return facades.Schema().Create("busgroup_modules", func(table schema.Blueprint) {
			table.BigInteger("busgroup_id")
			table.BigInteger("module_id")
			table.Index("busgroup_id", "module_id")
		})
	}

	return nil
}

// Down Reverse the migrations.
func (r *M20250303170434CreateBusgroupModulesTable) Down() error {
	return facades.Schema().DropIfExists("busgroup_modules")
}
